<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    /*var suer = {
        name:"唐科文",
        age:20,
        gender:"male",
        eat:function(){
            alert("用膳~~~");
        },

    }
    console.log(suer.age),
        suer.eat();*/
    //定义json
    var jsonstr='{"name":"Tom","age":20,"addr":["北京","重庆","成都"]}';
    alert(jsonstr.name);
    //json字符串--js对象
    var obj=JSON.parse(jsonstr);
    alert(obj.age);
    //js对象--json字符串
    alert(JSON.stringify(obj));
</script>
</body>
</html>